#!/bin/sh

echo "============start init=================="
php="/usr/bin/php"
pecl="/usr/bin/pecl"
phar="/usr/bin/phar"
config="/usr/bin/php-config"
phpize="/usr/bin/phpize"
fpm="/usr/sbin/php-fpm"

PHP_MINOR_VERSION=$(php82 -r "echo PHP_MINOR_VERSION;")
PHP_MAJOR_VERSION=$(php82 -r "echo PHP_MAJOR_VERSION;")

# if [ ! -L  "$fpm" ];then
#     echo 'fpm 软连接不存在'
#     ln -s /usr/sbin/php-fpm"${PHP_MINOR_VERSION}""${PHP_MINOR_VERSION}" /usr/sbin/php-fpm
# fi

if [ ! -L  "$php" ];then
    echo 'php 软连接不存在'
    ln -s /usr/bin/php"${PHP_MAJOR_VERSION}""${PHP_MINOR_VERSION}" /usr/bin/php
fi

if [ ! -L  "$pecl" ];then
    echo 'pecl 软连接不存在'
    ln -s /usr/bin/pecl"${PHP_MAJOR_VERSION}""${PHP_MINOR_VERSION}" /usr/bin/pecl
fi

if [ ! -L  "$phar" ];then
    echo 'phar 软连接不存在'
    ln -s /usr/bin/phar"${PHP_MAJOR_VERSION}""${PHP_MINOR_VERSION}" /usr/bin/phar
fi

if [ ! -L  "$phpize" ];then
    echo 'phpize 软连接不存在'
    ln -s /usr/bin/phpize"${PHP_MAJOR_VERSION}""${PHP_MINOR_VERSION}" /usr/bin/phpize
fi

if [ ! -L  "$config" ];then
    echo 'config 软连接不存在'
    ln -s /usr/bin/php-config"${PHP_MAJOR_VERSION}""${PHP_MINOR_VERSION}" /usr/bin/php-config
fi

echo "============end init===================="